@extends('admin.master')

@section('top')
	<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
	<div class="top-btn-group pull-right">
		<a href="{{ route('admin.menu.create') }}" class="btn btn-primary">添加菜单</a>
	</div>
@endsection

@section('content')
{!! Form::open(['url'=>'admin/menu/sort']) !!}
	<table class="table table-hover table-list">
		<thead>
			<tr>
				<th width="65">顺序</th>
				<th>菜单名称</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
		@foreach ($menuTree as $value)
			<tr>
				<td><input type="text" name="order[{{ $value['id'] }}]" size="2" value="{{ $value['order'] }}" class="form-control input-sm"></td>
				<td>{{ $value['name'] }}</td>
				<td class="text-right">
					<div class="toolbar">
						<a href="{{ route('admin.menu.edit', $value['id']) }}" class="btn-link">修改</a>
						<span class="text-explode ">|</span>
						<a href="javascript:void(0);" data-id="{{ $value['id'] }}" class="btn-link delete-item">删除</a>
					</div>
				</td>
			</tr>
			@if (isset($value['children']) && !empty($value['children']))
				@foreach ($value['children'] as $children)
				<tr>
					<td><input type="text" name="order[{{ $children['id'] }}]" size="2" value="{{ $children['order'] }}" class="form-control input-sm"></td>
					<td class="menu-son">{{ $children['name'] }}</td>
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.menu.edit', $children['id']) }}" class="btn-link">修改</a>
							<span class="text-explode ">|</span>
							<a href="javascript:void(0);" data-id="{{ $children['id'] }}" class="btn-link delete-item">删除</a>
						</div>
					</td>
				</tr>
				@if (isset($children['children']) && !empty($children['children']))
					@foreach ($children['children'] as $children2)
					<tr>
						<td><input type="text" name="order[{{ $children2['id'] }}]" size="2" value="{{ $children2['order'] }}" class="form-control input-sm"></td>
						<td class="menu-son-1"><i class="class="menu-tree-icon""></i>{{ $children2['name'] }}</td>
						<td class="text-right">
							<div class="toolbar">
								<a href="{{ route('admin.menu.edit', $children2['id']) }}" class="btn btn-sm btn-default">修改</a>
								<a href="javascript:void(0);" data-id="{{ $children2['id'] }}" class="btn btn-sm btn-default delete-item">删除</a>
							</div>
						</td>
					</tr>
					@endforeach
				@endif
				@endforeach
			@endif
		@endforeach
		</tbody>
		<tfoot>
			<tr>
				<td colspan="3">
					<div class="pull-left">
						{!! Form::submit('排序', ['class'=>'btn btn-primary']) !!}
					</div>
				</td>
			</tr>
		</tfoot>
	</table>
{!! Form::close() !!}
@endsection

@section('foot')
<script src="{{ url('js/bootstrap.min.js') }}"></script>
@endsection